package com.atguigu.scheduled;

import com.atguigu.constant.MqConst;
import com.atguigu.constant.RedisConst;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author ：Hachimen
 * @date ：Created in 2021/9/15 18:33
 * @description：
 * @modified By：
 * @version:
 */
@Component
@EnableScheduling
public class ScheduledJob {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Scheduled(cron = "0 0 5 * * ? ")
    public void task01Start(){
        System.out.println("秒杀上架定时任务启动！");
        rabbitTemplate.convertAndSend(MqConst.SCAN_SECKILL_EXCHANGE,MqConst.SCAN_SECKILL_ROUTE_KEY,"");
    }

    @Scheduled(cron = "0 0 2 * * ? ")
    public void task01End(){
        System.out.println("秒杀下架定时任务启动！");
        rabbitTemplate.convertAndSend(MqConst.CLEAR_REDIS_EXCHANGE,MqConst.CLEAR_REDIS_ROUTE_KEY,"");
    }
}
